package com.ruoyi.web.controller.house;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.houseInformation.domain.HouseDoorInformation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projectRequest.domain.HouseProjectRequest;
import com.ruoyi.projectRequest.service.IHouseProjectRequestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修申请Controller
 * 
 * @author lijie
 * @date 2023-07-27
 */
@RestController
@RequestMapping("/house/projectRequest")
public class HouseProjectRequestController extends BaseController
{
    @Autowired
    private IHouseProjectRequestService houseProjectRequestService;

    /**
     * 查询维修申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HouseProjectRequest houseProjectRequest)
    {
        startPage();
        List<HouseProjectRequest> list = houseProjectRequestService.selectHouseProjectRequestList(houseProjectRequest);
        return getDataTable(list);
    }

    /**
     * 导出维修申请列表
     */
    @Log(title = "维修申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseProjectRequest houseProjectRequest)
    {
        List<HouseProjectRequest> list = houseProjectRequestService.selectHouseProjectRequestList(houseProjectRequest);
        ExcelUtil<HouseProjectRequest> util = new ExcelUtil<HouseProjectRequest>(HouseProjectRequest.class);
        util.exportExcel(response, list, "维修申请数据");
    }

    @GetMapping(value = "/housePass/{batchIds}")
    public AjaxResult housePass(@PathVariable("batchIds") Long[] batchIds)
    {
        HouseProjectRequest houseProjectRequest = new HouseProjectRequest();
        houseProjectRequest.setInformationSts("1");
        return toAjax(houseProjectRequestService.updateStsById(batchIds, houseProjectRequest));
    }

    @GetMapping(value = "/houseRefuse/{batchIds}")
    public AjaxResult houseRefuse(@PathVariable("batchIds") Long[] batchIds)
    {
        HouseProjectRequest houseProjectRequest = new HouseProjectRequest();
        houseProjectRequest.setInformationSts("2");
        return toAjax(houseProjectRequestService.updateStsById(batchIds, houseProjectRequest));
    }

}
